package com.appwoo.txtws.component;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.media.AudioManager;

public class VolumeCtrl
{
  public static int ctrl = -1;
  private static final int[] vols = { 1, 2, 3, 4 };

  public static int isHasRing(Context paramContext)
  {
    return ((AudioManager)paramContext.getSystemService("audio")).getStreamVolume(2);
  }

  public static void recoverVolume(Context paramContext)
  {
    AudioManager localAudioManager = (AudioManager)paramContext.getSystemService("audio");
    SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("firstLogin", 0);
    int[] arrayOfInt = { localSharedPreferences.getInt("sys", 5), localSharedPreferences.getInt("ring", 5), localSharedPreferences.getInt("music", 5), localSharedPreferences.getInt("alarm", 5) };
    for (int i = 0; ; i++)
    {
      if (i >= arrayOfInt.length)
        return;
      localAudioManager.setStreamVolume(vols[i], arrayOfInt[i], 0);
      Logger.i("xjf", "恢复音量" + arrayOfInt[i]);
    }
  }

  public static void ring(Context paramContext)
  {
    if ((ctrl == -1) || (ctrl == 0))
    {
      AudioManager localAudioManager = (AudioManager)paramContext.getSystemService("audio");
      SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("firstLogin", 0);
      if (localSharedPreferences.getBoolean("isset", false))
      {
        localAudioManager.setRingerMode(localSharedPreferences.getInt("mode", 2));
        localAudioManager.setVibrateSetting(0, localSharedPreferences.getInt("ringer", 1));
        localAudioManager.setVibrateSetting(1, localSharedPreferences.getInt("noti", 1));
        Logger.d("vol", ctrl + " recover1");
      }
      ctrl = 1;
      Logger.d("vol", ctrl + " recover2");
    }
  }

  public static void ringAndVibrate(Context paramContext)
  {
    AudioManager localAudioManager = (AudioManager)paramContext.getSystemService("audio");
    localAudioManager.setRingerMode(2);
    localAudioManager.setVibrateSetting(0, 1);
    localAudioManager.setVibrateSetting(1, 1);
  }

  public static void saveVolume(Context paramContext)
  {
    AudioManager localAudioManager = (AudioManager)paramContext.getSystemService("audio");
    int i = localAudioManager.getStreamVolume(1);
    int j = localAudioManager.getStreamVolume(2);
    int k = localAudioManager.getStreamVolume(3);
    int m = localAudioManager.getStreamVolume(4);
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("firstLogin", 0).edit();
    localEditor.putInt("sys", i);
    localEditor.putInt("ring", j);
    localEditor.putInt("music", k);
    localEditor.putInt("alarm", m);
    localEditor.commit();
    Logger.w("xjf", "\nsys:" + i + "\nring:" + j + "\nmusic:" + k + "\nalarm:" + m);
  }

  public static void setMinVolume(Context paramContext)
  {
    AudioManager localAudioManager = (AudioManager)paramContext.getSystemService("audio");
    for (int i = 0; ; i++)
    {
      if (i >= vols.length)
        return;
      localAudioManager.setStreamVolume(vols[i], 0, 0);
    }
  }

  public static void silent(Context paramContext)
  {
    AudioManager localAudioManager = (AudioManager)paramContext.getSystemService("audio");
    if ((ctrl == -1) || (ctrl == 1))
    {
      SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("firstLogin", 0);
      if (!localSharedPreferences.getBoolean("isset", false))
      {
        int i = localAudioManager.getRingerMode();
        int j = localAudioManager.getVibrateSetting(0);
        int k = localAudioManager.getVibrateSetting(1);
        SharedPreferences.Editor localEditor = localSharedPreferences.edit();
        localEditor.putInt("mode", i);
        localEditor.putInt("ringer", j);
        localEditor.putInt("noti", k);
        localEditor.putBoolean("isset", true);
        localEditor.commit();
        Logger.d("vol", ctrl + " jingyin--一设置静音了");
      }
      ctrl = 0;
      Logger.d("vol", ctrl + " jingyin");
    }
    localAudioManager.setRingerMode(0);
    localAudioManager.setVibrateSetting(0, 0);
    localAudioManager.setVibrateSetting(1, 0);
  }

  public static void vibrate(Context paramContext)
  {
    AudioManager localAudioManager = (AudioManager)paramContext.getSystemService("audio");
    localAudioManager.setRingerMode(1);
    localAudioManager.setVibrateSetting(0, 1);
    localAudioManager.setVibrateSetting(1, 1);
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.component.VolumeCtrl
 * JD-Core Version:    0.6.2
 */